﻿using Sustainalytics.Entities;
using System;
using System.Collections.Generic;
using System.Security.Claims;

namespace Sustainalytics.Claims.BL
{
    public class ClaimMapComparer : IClaimMapComparer
    {
        public bool Diff(ClaimMap leftClaimMap, ClaimMap rightClaimMap, out bool diffPermission, out List<Claim> leftAdd, out List<Claim> rightAdd)
        {
            if (leftClaimMap == null)
                throw new ArgumentException("Left claim map should not be null!");

            if (rightClaimMap == null)
                throw new ArgumentException("Right claim map should not be null!");

            leftAdd = null;
            rightAdd = null;
            diffPermission = false;

            if (leftClaimMap.Permission != rightClaimMap.Permission)//names should be enough
            {
                diffPermission = true;
                return true;
            }

            return UserMapComparer.DiffClaims(leftClaimMap.Claims, rightClaimMap.Claims, out leftAdd, out rightAdd);
        }
    }
}
